<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>修改用户角色信息</title>
</head>
<style type="text/css">
	th{font-size:20px;padding:20px;}
	td{text-align:right;line-height:2em;}

form {
	width: 35%;
	margin: auto;
}
</style>
<%
	String path = request.getContextPath();
	request.setAttribute("path", request.getContextPath());
	request.setAttribute("jsPath", path + "/js");
%>
<script type="text/javascript" src="${jsPath}/jquery-1.8.3.min.js"></script>
<script type="text/javascript">
	$(function() {
		/* var msg = $("#msg").html();
		if (msg != null) {
			alert(msg);
		} */
	});
	
	function sub() {
		 $.ajax({
             type: 'post',
             url: '<%=path%>/userRole/updAjax',
				data : {
					'roleId' : $('#roleId').val()
				},
				dataType : 'json',
				success : function(data) {
					if (data == 0) {
						alert('来吃炮');
						st = 4;
					}
					if (data == 2) {
						alert('没有这个职位');
					}					
				},
				error : function(error) {
					alert('数据库没有这个值');
				}
			});
			//  alert(st);
			if (st == 4) {
				alert("1");
				return true;
			} else {
				alert("2");
				return false;
			}
	}

	/* function checkChnName(){
		var reg=/^[\u4e00-\u9fa5]{0,16}$/;//{0,16} 这里是中文字符数
		var $chnName=$("#chnName");
		if($chnName.val()==""){
			$chnName.next().text("中文姓名不能为空!");
			
			return false;
		}
		if(!reg.test($chnName.val())){
			$chnName.next().text("姓名必须是中文且最多16个字符!");

			return false;
		}	
		$chnName.next().text("")
		return true;
	} */
</script>
<body>
	<c:if test="${not empty msg}">
		<p style="display: none" id="msg">${msg}</p>
	</c:if>
	<form action="${path}/userRole/update" method="post" id="form1" onsubmit="return sub()">
		<table>
			<tr>
				<th colspan="2">修改用户角色信息</th>
			</tr>
			<tr>
				<td>用户名称：</td>
				<td><input type="text" name="chnName"
					value="${userRole.chnName}" id="chnName" /><input type="hidden"
					id="userRoleId" name="userRoleId" value="${userRole.userRoleId}" />
					<%-- <input
					type="hidden" name="userRoleId" value="${userRole.}"> --%></td>
			</tr>
			<tr>
				<td>职位：</td>
				<td style="text-align:left;"><select name="roleId" id="roleId">
						<c:forEach items="${sysRoles}" var="sys">
							<c:if test="${sys.roleId == userRole.roleId}">
								<option value="${sys.roleId}" selected="selected">${sys.name}</option>
							</c:if>
							<c:if test="${sys.roleId != userRole.userRoleId}">
								<option value="${sys.roleId}">${sys.name}</option>	
							</c:if>
							
						</c:forEach>
				</select></td>
			</tr>
			<tr>
				<td></td>
				<td style="text-align: left;"><input type="reset" value="重置" />
					<input type="submit" value="修改" /></td>
			</tr>
		</table>
	</form>
</body>
</html>